home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 41 / Amiga Format CD41 (1999-06)(Future Publishing)(GB)[!][issue 1999-07].iso / -seriously_amiga- / programming / other / gtlayout / source / ltp_getcommandwidth.c < prev    next >
C/C++ Source or Header  |  1999-04-19  |  888b  |  49 lines

  1. /*
  2. **    GadTools layout toolkit
  3. **
  4. **    Copyright © 1993-1998 by Olaf `Olsen' Barthel
  5. **        Freely distributable.
  6. **
  7. **    :ts=4
  8. */
  9.  
  10. #ifndef _GTLAYOUT_GLOBAL_H
  11. #include "gtlayout_global.h"
  12. #endif
  13.  
  14. #include "Assert.h"
  15.  
  16. #ifdef DO_MENUS    /* Support code */
  17.  
  18.     /* LTP_GetCommandWidth(RootMenu *Root,ItemNode *Item):
  19.      *
  20.      *    Calculate the width of a command sequence.
  21.      */
  22.  
  23. LONG
  24. LTP_GetCommandWidth(RootMenu *Root,ItemNode *Item)
  25. {
  26.     LONG Width = 0;
  27.  
  28.         // Skip separator bars
  29.  
  30.     if(!(Item->Flags & ITEMF_IsBar))
  31.     {
  32.             // Add in the Amiga glyph
  33.  
  34.         if(Item->Item.Flags & COMMSEQ)
  35.             Width = TextLength(&Root->RPort,&Item->Item.Command,1) + 2 + Root->AmigaWidth + 2;
  36.         else
  37.         {
  38.                 // Add in command or submenu indicator
  39.  
  40.             if(Item->Flags & (ITEMF_Command | ITEMF_HasSub))
  41.                 Width = IntuiTextLength(((struct IntuiText *)Item->Item.ItemFill)->NextText) + 2;
  42.         }
  43.     }
  44.  
  45.     return(Width);
  46. }
  47.  
  48. #endif    /* DO_MENUS */
  49.